import mittBus from "/@/utils/mitt";
import { useRoute } from "vue-router";

export default function useTagsView() {

    const route = useRoute();

    // 刷新当前
    const refreshTagsView = () => {
        mittBus.emit(
            "onCurrentContextmenuClick",
            Object.assign({}, { contextMenuClickId: 0, ...route })
        );
    }

    // 关闭当前
    const removeTagsView = () => {
        mittBus.emit(
            "onCurrentContextmenuClick",
            Object.assign({}, { contextMenuClickId: 1, ...route })
        );
    }

    // 关闭其他
    const removeOtherTagsView = () => {
        mittBus.emit(
            "onCurrentContextmenuClick",
            Object.assign({}, { contextMenuClickId: 2, ...route })
        );
    }

    // 全部关闭
    const removeAllTagsView = () => {
        mittBus.emit(
            "onCurrentContextmenuClick",
            Object.assign({}, { contextMenuClickId: 3, ...route })
        );
    }

    return {
        refreshTagsView,
        removeTagsView,
        removeOtherTagsView,
        removeAllTagsView
    }
}